using MicroMsg.Common.Utils;
using MicroMsg.Resource.@string;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace MicroMsg.UI.UserContrl
{
	public class ImageConfirmControl : UserControl
	{
		private const string TAG = "ImageConfirmControl";
		private Stream currentImgStream;
		private ImageConfirmOk currentOnImgOkEvent;
		private BasePage fatherPage;
		private ApplicationBar mAppBar;
		internal Grid LayoutRoot;
		internal Image ShowImg;
		private bool _contentLoaded;
		public ImageConfirmControl()
		{
			this.InitializeComponent();
		}
		public void StartImageConfirm(BasePage originPage, Stream imgStream, ImageConfirmOk onImgOkEvent)
		{
			this.currentImgStream = imgStream;
			this.currentOnImgOkEvent = onImgOkEvent;
			this.fatherPage = originPage;
			this.fatherPage.set_ApplicationBar(this.GetApplicationBar());
			BitmapImage bitmapImage = new BitmapImage();
			bitmapImage.SetSource(imgStream);
			this.ShowImg.set_Source(bitmapImage);
			Log.smethod_5("ImageConfirmControl", "StartImageConfirm");
		}
		public ApplicationBar GetApplicationBar()
		{
			if (this.mAppBar != null)
			{
				return this.mAppBar;
			}
			this.mAppBar = new ApplicationBar();
			this.mAppBar.set_IsMenuEnabled(true);
			this.mAppBar.set_IsVisible(true);
			this.mAppBar.set_Opacity(0.75);
			ApplicationBarIconButton applicationBarIconButton = new ApplicationBarIconButton(new Uri("/icons/appbar.check.rest.png", 2));
			applicationBarIconButton.set_Text(strings.COM_Confirm);
			applicationBarIconButton.add_Click(new EventHandler(this.OkBtn_Click));
			this.mAppBar.get_Buttons().Add(applicationBarIconButton);
			return this.mAppBar;
		}
		private void OkBtn_Click(object sender, EventArgs e)
		{
			if (this.currentImgStream != null && this.currentOnImgOkEvent != null)
			{
				this.currentOnImgOkEvent(this.currentImgStream);
				this.ClearData();
				base.set_Visibility(1);
				return;
			}
		}
		public void ClearData()
		{
			if (this.fatherPage != null)
			{
				this.fatherPage.set_ApplicationBar(null);
			}
			this.fatherPage = null;
			this.currentImgStream = null;
			this.currentOnImgOkEvent = null;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/ImageConfirmControl.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.ShowImg = (Image)base.FindName("ShowImg");
		}
	}
}
